package com.example.cart.dao.po;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("cart")
public class Cart {
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    @TableField(value = "user_id")
    private Long userId;
    @TableField(value = "product_id")
    private Long productId;
    @TableField(value = "quantity")
    private Long quantity;
    @TableField(value = "update_time")
    private Date updateTime;
}

//CREATE TABLE `cart` (
//    `id` BIGINT NOT NULL AUTO_INCREMENT,
//    `user_id` BIGINT NOT NULL COMMENT '用户ID',
//    `product_id` BIGINT NOT NULL COMMENT '商品ID',
//    `quantity` BIGINT NOT NULL DEFAULT 0 CHECK (quantity >= 0),
//    `update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
//    PRIMARY KEY (`id`),
//    UNIQUE KEY `uniq_user_product` (`user_id`,`product_id`)
//    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
